package com.itheima.app.controller;

import com.itheima.app.manager.SettingMananger;
import com.itheima.domain.db.Notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SettingController {
    @Autowired
    SettingMananger settingMananger;

    //查询通知
    @GetMapping("/users/settings")
    public ResponseEntity findSetting(){
        return settingMananger.findSetting();
    }

    //设置问题
    @PostMapping("/users/questions")
    public ResponseEntity setQuestion(@RequestBody Map<String,String> map){
        String content = map.get("content");
        return settingMananger.setQuestion(content);
    }

    //设置通知
    @PostMapping("/users/notifications/setting")
    public ResponseEntity setNotification(@RequestBody Notification notification){
        return settingMananger.setNotification(notification);
    }

    //分页查询黑名单
    @GetMapping("/users/blacklist")
    public ResponseEntity findBlackListByPage(
            @RequestParam(defaultValue = "1",value = "page") Integer pageNum,
            @RequestParam(defaultValue = "10",value = "pagesize") Integer pageSize){
        return settingMananger.findBlackListByPage(pageNum,pageSize);
    }

    //移除黑名单
    @DeleteMapping("/users/blacklist/{blackId}")
    public ResponseEntity deleteBlackList(@PathVariable Long blackId){
        return settingMananger.deleteBlackList(blackId);
    }

}
